package com.yueka.service.Impl;

import com.yueka.mapper.CourseMapper;
import com.yueka.mapper.CourseRecordMapper;
import com.yueka.mapper.StudentMapper;
import com.yueka.pojo.course.Course;
import com.yueka.pojo.course.CourseRecord;
import com.yueka.pojo.student.Student;
import com.yueka.pojo.studentSystem.Info;
import com.yueka.service.StudentSystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentSystemServiceimpl implements StudentSystemService {
    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private CourseMapper courseMapper;

    @Autowired
    private CourseRecordMapper courseRecordMapper;

    @Override
    public Student login(String phone, String studentName) {
        Student student = studentMapper.selectByPhone(phone, studentName);
        if (student == null) {
            throw new RuntimeException("您的信息未查询到，如有疑问，请联系管理员！");
        }
        return student;
    }

    @Override
    public Info info(Integer studentId) {
        return courseMapper.selectInfo(studentId);
    }

    @Override
    public List<Course> courseList(Integer studentId) {
        return courseMapper.selectCourseList(studentId);
    }

    @Override
    public List<CourseRecord> courseDetail(Integer courseId) {
        return courseRecordMapper.selectByCourseId(courseId);
    }
}
